<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="body">
			<h:form onkeypress="if (event.keyCode == 13) return false;">

				<rich:notifyMessages stayTime="2000" nonblocking="true" />

				<h:panelGrid>
					<rich:panel header="#{msg.search}" rendered="#{massScheduleManageBean.status == 'INIT'}">
						<table>
							<tr>
								<td><h:outputText value="#{msg.building_name}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td><h:selectOneMenu id="search_building_name" styleClass="selectClass" value="#{massScheduleManageBean.selectedBuildingId}" valueChangeListener="#{massScheduleManageBean.buildingValueChanged}">

										<f:selectItems value="#{massScheduleManageBean.buildingOptions}" />
										<a4j:ajax event="valueChange" render="search_floor_name,search_room_name,search_machine_name" execute="@this" />

									</h:selectOneMenu></td>

								<td><h:outputText value="#{msg.floor_name}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td><h:selectOneMenu id="search_floor_name" styleClass="selectClass" value="#{massScheduleManageBean.selectedFloorId}" valueChangeListener="#{massScheduleManageBean.floorValueChanged}">

										<f:selectItems value="#{massScheduleManageBean.floorOptions}" />
										<a4j:ajax event="valueChange" render="search_room_name,search_machine_name" execute="@this" />
									</h:selectOneMenu></td>
							</tr>

							<tr>
								<td><h:outputText value="#{msg.room_name}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td><h:selectOneMenu id="search_room_name" styleClass="selectClass" value="#{massScheduleManageBean.selectedRoomId}" valueChangeListener="#{massScheduleManageBean.roomValueChanged}">

										<f:selectItems value="#{massScheduleManageBean.roomOptions}" />
										<a4j:ajax event="valueChange" render="search_machine_name" execute="@this" />

									</h:selectOneMenu></td>

								<td><h:outputText value="#{msg.machine_name}" styleClass="outputText" style="font-size: 16px;" /></td>
								<td><h:selectOneMenu id="search_machine_name" styleClass="selectClass" value="#{massScheduleManageBean.selectedMachineId}">

										<f:selectItems value="#{massScheduleManageBean.machineOptions}" />
									</h:selectOneMenu></td>
							</tr>

							<tr>
								<td colspan="4" align="right">
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.search}" 
										action="#{massScheduleManageBean.search}" 
										render="@form" />
								</td>

							</tr>
						</table>
					</rich:panel>

					<rich:panel id="select_pane" header="#{msg.select}" rendered="#{massScheduleManageBean.status == 'SELECT'}">

						<table>
							<tr>
								<td>
									<h:selectManyCheckbox id="clickedMachine" layout="pageDirection" style="font-size: 16px;" value="#{massScheduleManageBean.clickedMachineId}">
										<f:selectItems value="#{massScheduleManageBean.clickedMachineOptions}" />
									</h:selectManyCheckbox> <h:outputText value="#{msg.no_record_found}" rendered="#{empty massScheduleManageBean.clickedMachineOptions}" />
								</td>
							</tr>
							<tr>
								<td>
									<a4j:commandLink value="#{msg.select_all}"
										action="#{massScheduleManageBean.selectAll}"
										render="@form"/>
									<h:outputText value="&#160;" />		
									<h:outputText value="&#160;" />
									<a4j:commandLink value="#{msg.clear}"
										action="#{massScheduleManageBean.clear}"
										render="@form"/>	
								</td>
							</tr>
							<tr>
								<td align="right">
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
										value="#{msg.back}"
										action="#{massScheduleManageBean.init}" 
										render="@form" /> 
									<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;"
										value="#{msg.select}" action="#{massScheduleManageBean.view}" 										
										render="@form" />
								</td>
							</tr>
						</table>
					</rich:panel>

					<rich:panel id="control_pane" header="#{msg.mass_schedule_control}" rendered="#{massScheduleManageBean.status == 'CONTROL'}">
						<table>
							<tr>
								<td  valign="top" style="font-size: 16px;">
									<rich:panel header="#{msg.selected_machine}">
										<a4j:repeat value="#{massScheduleManageBean.selectedMachines}" var="machine" rows="16" id="repeat">
											<h:panelGrid>
												<h:outputText value="#{machine.room.floor.building.buildingName}, #{machine.room.floor.floorName}, #{machine.room.roomName}, #{machine.machineName}" />
											</h:panelGrid>										
										</a4j:repeat>	
										<a4j:outputPanel layout="block">
							                <rich:dataScroller for="repeat" render="control_pane" maxPages="3"/>
							            </a4j:outputPanel>
							         </rich:panel>								
								</td>
								
								<td valign="top" style="font-size: 16px;">
									<rich:panel header="#{msg.schedule}">
									<table>
											<tr>
												<td>
													<h:outputText value="#{msg.time}" styleClass="outputText" style="font-size: 16px;"/>
													<h:outputText value="&#160;" />	
												</td>
												<td>
													<h:selectOneMenu styleClass="short_selectClass2"			                			
														value="#{massScheduleManageBean.editItem.scheduleHour}" >	
														<f:selectItems value="#{massScheduleManageBean.hourOptions}" />														
													</h:selectOneMenu>	
													<h:outputText value=":" styleClass="outputText" style="font-size: 16px;"/>
													<h:selectOneMenu styleClass="short_selectClass2"			                			
														value="#{massScheduleManageBean.editItem.scheduleMin}" >	
														<f:selectItems value="#{massScheduleManageBean.minuteOptions}" />														
													</h:selectOneMenu>
												</td>
											</tr>
											
											<tr>
												<td>
													<h:outputText value="#{msg.start_option}" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												<td>
													<h:selectOneMenu 
														styleClass="selectClass" value="#{massScheduleManageBean.editItem.start}" >									
														<f:selectItem itemLabel="#{msg.start_on}" itemValue="#{true}" />
														<f:selectItem itemLabel="#{msg.start_off}" itemValue="#{false}" />
													</h:selectOneMenu>
												</td>
											</tr>
												
											<tr>
												
												<td>
													<h:outputText value="#{msg.fan_speed}" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												
												
												<td>
													<h:selectOneMenu 
														styleClass="selectClass" value="#{massScheduleManageBean.editItem.fanSpeed}" >									
														<f:selectItem itemLabel="#{msg.fan_speed_auto}" itemValue="#{0}" />
														<f:selectItem itemLabel="#{msg.fan_speed_high}" itemValue="#{1}" />
														<f:selectItem itemLabel="#{msg.fan_speed_mid}" itemValue="#{2}" />
														<f:selectItem itemLabel="#{msg.fan_speed_low}" itemValue="#{3}" />
														
													</h:selectOneMenu>
												</td>
																				
											</tr>
											
											<tr>
												<td>
													<h:outputText value="#{msg.temperature}(#{msg.celsius})" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												<td>
													<h:selectOneMenu 
														styleClass="selectClass" value="#{massScheduleManageBean.editItem.temperature}" >									
														<f:selectItems value="#{massScheduleManageBean.temperatureOptions}" />
													</h:selectOneMenu>
												</td>
											</tr>	
											
											<tr>
												<td>
													<h:outputText value="#{msg.minimum_temperature}(#{msg.celsius})" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												<td>
													<h:selectOneMenu 
														styleClass="selectClass" value="#{massScheduleManageBean.editItem.minimumTemperature}" >									
														<f:selectItems value="#{massScheduleManageBean.minimumTemperatureOptions}" />
													</h:selectOneMenu>
												</td>
											</tr>		
											
											<tr>
												<td>
													<h:outputText value="#{msg.key_lock}" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												<td>
													<h:selectOneMenu 
														styleClass="selectClass" value="#{massScheduleManageBean.editItem.keyLock}" >									
														<f:selectItem itemLabel="#{msg.key_lock_no_lock}" itemValue="#{0}" />
														<f:selectItem itemLabel="#{msg.key_lock_fan_speed_only}" itemValue="#{1}" />
													</h:selectOneMenu>
												</td>
											</tr>																																									
											
											
											<tr>
												<td>
													<h:outputText value="#{msg.status}" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
						                		<td>
							                		<h:selectOneMenu styleClass="selectClass" value="#{massScheduleManageBean.editItem.active}" >	
														<f:selectItem itemLabel="Y" itemValue="#{true}" />
														<f:selectItem itemLabel="N" itemValue="#{false}" />													
													</h:selectOneMenu>			                	
						                		</td>    
											</tr>
											
											<tr>
												<td>
													<h:outputText value="#{msg.schedule}" styleClass="outputText" style="font-size: 16px;" />
													<h:outputText value="&#160;" />	
												</td>
												<td>
													#{msg.monday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execMon}" />
													#{msg.tuesday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execTue}" />
													#{msg.wednesday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execWed}" />
												</td>
											</tr>
											
											<tr>
												<td>
													
												</td>
												<td>
													#{msg.thusday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execThu}" />
													#{msg.friday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execFri}" />
													#{msg.saturday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execSat}" />
												</td>
											</tr>
											
											<tr>
												<td></td>
												<td>
													#{msg.sunday}<h:selectBooleanCheckbox value="#{massScheduleManageBean.editItem.execSun}" />											
												</td>
											</tr>
											
											<tr>
												<td colspan="2" align="right">	
													<a4j:commandButton styleClass="buttonClass" style="font-size: 16px;" 
														value="#{msg.back}"
														action="#{massScheduleManageBean.init}" 
														render="@form" />								
													<a4j:commandButton 
														id="send_btn"
														styleClass="buttonClass" style="font-size: 16px;" 
														value="#{msg.apply}" action="#{massScheduleManageBean.apply}" 
														render="@form"/>																
												</td>
											</tr>
										</table>		
									
									</rich:panel>
								</td>
							</tr>
							
						</table>
					</rich:panel>
				

				</h:panelGrid>

			</h:form>

		</ui:define>
	</ui:composition>
</body>
</html>
